package com.qinggeng.project.system.typehandler;

import com.alibaba.fastjson.JSONObject;
import com.qinggeng.project.system.domain.vo.JobMessageContentPositionVO;
import com.qinggeng.project.system.domain.vo.JobMessageContentResumeVO;
import org.apache.ibatis.type.JdbcType;
import org.apache.ibatis.type.MappedJdbcTypes;
import org.apache.ibatis.type.TypeHandler;

import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;


@MappedJdbcTypes(JdbcType.VARCHAR)
public class JobMessageContentPositionVOTypeHandler implements TypeHandler<JobMessageContentPositionVO> {



    @Override
    public void setParameter(PreparedStatement ps, int i, JobMessageContentPositionVO parameter, JdbcType jdbcType) throws SQLException {
        ps.setString(i, JSONObject.toJSONString(parameter));
    }

    @Override
    public JobMessageContentPositionVO getResult(ResultSet rs, String columnName) throws SQLException {
        return JSONObject.parseObject(rs.getString(columnName),JobMessageContentPositionVO.class);
    }

    @Override
    public JobMessageContentPositionVO getResult(ResultSet rs, int columnIndex) throws SQLException {

        return JSONObject.parseObject(rs.getString(columnIndex),JobMessageContentPositionVO.class);

    }

    @Override
    public JobMessageContentPositionVO getResult(CallableStatement cs, int columnIndex) throws SQLException {
        return null;
    }
}
